<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>开启/关闭自动渲染功能</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="class.yaf-dispatcher.html">« Yaf_Dispatcher</a></li>
      <li style="float: right;"><a href="yaf-dispatcher.catchexception.html">Yaf_Dispatcher::catchException »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="class.yaf-dispatcher.html">Yaf_Dispatcher</a></li>
    <li>开启/关闭自动渲染功能</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="yaf-dispatcher.autorender" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">Yaf_Dispatcher::autoRender</h1>
  <p class="verinfo">(Yaf &gt;=1.0.0)</p><p class="refpurpose"><span class="refname">Yaf_Dispatcher::autoRender</span> &mdash; <span class="dc-title">开启/关闭自动渲染功能</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-yaf-dispatcher.autorender-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><strong>Yaf_Dispatcher::autoRender</strong></span>(<span class="methodparam"><span class="type">bool</span> <code class="parameter">$flag</code></span>): <span class="type"><a href="class.yaf-dispatcher.html" class="type Yaf_Dispatcher">Yaf_Dispatcher</a></span></div>

  <p class="para rdfs-comment">
   在开启的情况下(Yaf默认开启)，action执行完成以后，<span class="classname"><a href="class.yaf-dispatcher.html" class="classname">Yaf_Dispatcher</a></span> 会自动调用view引擎去渲染该action对应的视图模板。
   你也可以通过调用这个函数并将 <code class="parameter">flag</code> 参数的值设为TRUE来人工干预它。
   <blockquote class="note"><p><strong class="note">注意</strong>: 
     <p class="para">
     你可以在一个action中仅仅返回FALSE来阻止当前action对应视图的自动渲染
    </p>
   </p></blockquote>
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-yaf-dispatcher.autorender-parameters">
  <h3 class="title">参数</h3>
  <dl>
   
    <dt>
<code class="parameter">flag</code></dt>

    <dd>

     <p class="para">
       bool
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-yaf-dispatcher.autorender-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">

  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-yaf-dispatcher.autorender-examples">
  <h3 class="title">范例</h3>
  <div class="example" id="example-3881">
   <p><strong>示例 #1 <span class="function"><strong>Yaf_Dispatcher::autoRender()</strong></span>example</strong></p>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">class&nbsp;</span><span style="color: #0000BB">IndexController&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">Yaf_Controller_Abstract&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;init&nbsp;method&nbsp;will&nbsp;be&nbsp;called&nbsp;as&nbsp;soon&nbsp;as&nbsp;a&nbsp;controller&nbsp;is&nbsp;initialized&nbsp;*/&nbsp;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #007700">public&nbsp;function&nbsp;</span><span style="color: #0000BB">init</span><span style="color: #007700">()&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if&nbsp;(</span><span style="color: #0000BB">$this</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getRequest</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">isXmlHttpRequest</span><span style="color: #007700">())&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">//do&nbsp;not&nbsp;call&nbsp;render&nbsp;for&nbsp;ajax&nbsp;request<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;//we&nbsp;will&nbsp;outpu&nbsp;a&nbsp;json&nbsp;string<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">Yaf_Dispatcher</span><span style="color: #007700">::</span><span style="color: #0000BB">getInstance</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">autoRender</span><span style="color: #007700">(</span><span style="color: #0000BB">FALSE</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}&nbsp;<br /><br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <div class="example-contents"><p>以上例程的输出类似于：</p></div>
   <div class="example-contents screen">
<div class="cdata"><pre>
</pre></div>
   </div>
  </div>
 </div>


</div></div></div></body></html>